export function orgAssignRoleColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      type: "expand",
      width: 45,
      align: "center",
      render: (h, params) => {
        return h(RoleAssignUser, {
          props: {
            roleId: params.row.id
          }
        });
      }
    },
    {
      title: this.$t("module.role.roleName"),
      key: "roleName",
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleName
            }
          },
          params.row.roleName
        );
      }
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 100,
      render: (h, params) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: "md-create",
                text: this.$t("common.edit"),
                handle: () => {
                  this.edit(params.row.id, params.row.version);
                }
              },
              {
                type: "icon",
                icon: "ios-body",
                text: this.$t("module.post.assignRole"),
                handle: () => {
                  this.assignRole(params.row);
                }
              },
              {
                type: "icon",
                icon: "md-people",
                text: this.$t("module.post.assignUser"),
                handle: () => {
                  this.assignUser(params.row);
                }
              }
            ]
          }
        });
      }
    }
  ];
}

export function orgSelectRoleColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.role.roleCode"),
      key: "roleCode",
      width: 200,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleCode
            }
          },
          params.row.roleCode
        );
      }
    },
    {
      title: this.$t("module.role.roleName"),
      key: "roleName",
      width: 200,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.roleName
            }
          },
          params.row.roleName
        );
      }
    },
    {
      title: this.$t("common.describe"), // 备注 改为 描述
      key: "remark",
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.remark
            }
          },
          params.row.remark
        );
      }
    }
  ];
}

export function roleAssignUserColumns() {
  const list = [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "userId", // "account", 数据中未找到 account
      minWidth: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userId
            }
          },
          params.row.userId
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "userName",
      minWidth: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userName
            }
          },
          params.row.userName
        );
      }
    },
    {
      title: this.$t("module.userManage.organization"),
      key: "orgPath",
      minWidth: 110,
      render: (h, params) => {
        if (params.row._hasOrgInfo) {
          return h(
            "div",
            {
              attrs: {
                class: "ivu-table-cell ivu-table-cell-ellipsis",
                title: params.row.orgNameFullPath
              }
            },
            params.row.orgName
          );
        } else {
          return h("Spin", [
            h("Icon", {
              props: {
                type: "ios-loading",
                size: 18
              },
              class: "spin-icon-load"
            })
          ]);
        }
      }
    },
    {
      title: this.$t("module.userManage.cellPhoneNumber"),
      key: "mobile",
      width: 120
    },
    {
      title: this.$t("module.userManage.email"),
      key: "email",
      minWidth: 160
    },
    {
      title: this.$t("common.status"), // 状态
      align: "left",
      key: "locked",
      width: 80,
      render: (h, params) => {
        return h(
          "StatusButton",
          {
            props: {
              status: params.row.locked
            }
          },
          params.row.locked == 0 ? this.$t("common.enable") : this.$t("common.disable")
        );
      }
    },
    {
      title: this.$t("common.operating"),
      align: "left",
      fixed: "right",
      width: 80,
      render: (h, params) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: "icon",
                icon: "ios-settings",
                text: this.$t("module.applicationSync.title"),
                hidden: this.roleCode !== 'developer' || !this.showSoftwareLicence,
                handle: () => {
                  this.goLicence(params);
                }
              },
            ]
          }
        });
      }
    }
  ];
  return list
}

// 选择用户
export function roleSelectUserColumns() {
  return [
    {
      type: "selection",
      width: 45,
      align: "center"
    },
    {
      title: this.$t("module.userManage.account"),
      key: "userId",
      width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userId
            }
          },
          params.row.userId
        );
      }
    },
    {
      title: this.$t("module.userManage.name"),
      key: "userName",
      width: 160,
      render: (h, params) => {
        return h(
          "div",
          {
            attrs: {
              class: "ivu-table-cell ivu-table-cell-ellipsis",
              title: params.row.userName
            }
          },
          params.row.userName
        );
      }
    },
    {
      title: this.$t("module.userManage.organization"),
      key: "orgPath",
      width: 160,
      render: (h, params) => {
        if (params.row._hasOrgInfo) {
          return h(
            "div",
            {
              attrs: {
                class: "ivu-table-cell ivu-table-cell-ellipsis",
                title: params.row.orgNameFullPath
              }
            },
            params.row.orgName
          );
        } else {
          return h("Spin", [
            h("Icon", {
              props: {
                type: "ios-loading",
                size: 18
              },
              class: "spin-icon-load"
            })
          ]);
        }
      }
    },
    {
      title: this.$t("module.userManage.cellPhoneNumber"),
      key: "mobile",
      width: 120
    },
    {
      title: this.$t("module.userManage.email"),
      key: "email"
    }
  ];
}
